package cm.org.birthday.web;

import cm.org.birthday.dao.BirthdayNoticeRepository;
import cm.org.birthday.domain.BirthdayNotice;
import cm.org.birthday.dto.BirthdayNoticeRequest;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;

/**
 * @Author: caomin
 * @Date: 2019年01月04日
 * @Description:
 */
@RestController
@RequestMapping("birthday")
public class BirthdayController {


    @Autowired
    private BirthdayNoticeRepository birthdayNoticeRepository;


    @RequestMapping("/")
    @PostMapping
    public void addBirthdayNotice(BirthdayNoticeRequest birthdayNoticeRequest) throws  Exception {
        BirthdayNotice birthdayNotice=new BirthdayNotice();
        BeanUtils.copyProperties(birthdayNoticeRequest, birthdayNotice);
        birthdayNoticeRepository.save(birthdayNotice);
    }


}
